home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
L' Effet Pommier 3
/
L'Effet Pommier - Volume 03.iso
/
Programmation
/
Gooey1.3.1
/
C Templates
/
mmAlert.c
< prev
next >
Wrap
Text File
|
1994-04-17
|
12KB
|
339 lines
$$Loop Alerts
$$Message MM Alert, mm:mmA_$Worksheet.name$.c
$$File mm:mmA_$Worksheet.name$.c
/* mmA_$Worksheet.name$ Handle this alert */
/* $CopyRight$ */
/* File name: mmA_$Worksheet.name$
Function: Handle this alert.
$$if Alert.Stop
This is a STOP alert, it is used to inform the user that data is about to be lost.
It is also used for fatal type errors and tells the user about the error.
$$endif
$$if Alert.Note
This is a NOTE alert, it is used to inform the user of some general information.
This alert is not used if there is a possibility of losing any data.
$$endif
$$if Alert.Caution
This is a CAUTION alert, it is used to inform the user that if the current path
is taken then data may be lost. The user can change the present course and
save the data. This is the type of alert used to tell the user that he needs to
save the data before going on.
$$endif
This alert is called when:
The choices in this alert allow for:
History: $Date$ Original by $Author$
*/
#include "mmCommon$Prototype.name$.h" /* Common */
#include "Common$Prototype.name$.h" /* Common */
#include "$Worksheet.name$.h" /* Users specific file */
#pragma segment Alerts
/* Prototype for filter routine */
static pascal Boolean MyFilter (DialogPtr theDialog,EventRecord *theEvent,short *itemHit);
/* ======================================================= */
/* Routine: MyFilter */
/* Purpose: Filter routine, also used for initial setup of dimmed states */
static pascal Boolean MyFilter (DialogPtr theDialog,EventRecord *theEvent,short *itemHit)
{
Boolean FilterValue; /* Temporary return value */
Rect tempRect; /* Temporary rectangle */
short DType; /* Type of dialog item */
Handle DItem; /* Handle to the dialog item */
ControlHandle CItem; /* Control handle */
short chCode; /* Key entered */
long LTemp,LTemp2; /* Used for time delay and HotSpot definitions */
$$if Worksheet.HasControls
RGBColor Saved_ForeColor; /* Place to save colors */
RGBColor Saved_BackColor; /* Place to save colors */
RGBColor DrawingColor; /* Place to make colors */
$$endif Worksheet.HasControls
FilterValue = false;
if (Rec_$Worksheet.name$.FirstTime) /* Make all controls and do lines and rects */
{
$$Loop Control.type = Button
SetupNormalControl(theDialog,ResA_$Control.name$,Rec_$Worksheet.name$.Enable_$Control.name$,0);
$$if Control.Default
/* This is the default selection, when RETURN is pressed. */
HiliteDefaultButton(theDialog,ResA_$Control.name$);
$$endif Control.Default
$$EndLoop Control.type
$$Loop Control.type = StaticText
$$if Control.SpecialText
/* Draw static text, $Control.FullName$ */
$$if Control.TextColor ! Black
if (Has.ColorQD) /* See if color QuickDraw is around */
{
DrawingColor.red = 0x$Control.RedTextColor$;
DrawingColor.green = 0x$Control.GreenTextColor$;
DrawingColor.blue = 0x$Control.BlueTextColor$;
RGBForeColor(&DrawingColor); /* Set the fore color */
RGBBackColor(&Saved_BackColor); /* Set the back color */
}
$$endif Control.TextColor
$$if Control.MultipleLine
SetRect(&tempRect,$Control.LeftPosition$,$Control.TopPosition$,$Control.RightPosition$,$Control.BottomPosition$);
DrawStaticTextBox(sResA_$Control.name$,&tempRect,$Control.TextAlignment$,$Control.TextSize$,$Control.TextFont$,$Control.TextStyle$);
$$endif Control.MultipleLine
$$if Control.SingleLine
DrawStaticLine(sResA_$Control.name$,$Control.LeftPosition$,$Control.TopPosition$,$Control.TextSize$,$Control.TextFont$,$Control.TextStyle$);
$$endif Control.SingleLine
$$if Control.TextColor ! Black
if (Has.ColorQD) /* See if color QuickDraw is around */
{
RGBForeColor(&Black_ForeColor); /* Set the fore color */
RGBBackColor(&White_BackColor); /* Set the back color */
}
$$endif Control.TextColor
$$endif
$$EndLoop
$$Loop Control.type = Icon
$$if Control.NonGraphic
/* Draw an Icon button */
SetupIconSicn(theDialog,ResA_$Control.name$,Rec_$Worksheet.name$.Enable_$Control.name$,
ResA_N_$Control.name$,ResA_H_$Control.name$);
$$endif Control.NonGraphic
$$EndLoop
$$Loop Control.type = Picture
$$if Control.NonGraphic
/* Draw a picture, $Control.FullName$ */
LTemp = ResA_N_$Control.name$; /* Picture ID and resize flag */
$$if Control.ClipPicture
LTemp = 0x00010000 | LTemp;
$$endif Control.ClipPicture
SetupTheItem(theDialog,ResA_$Control.name$,true,true,$Control.Active$,false,&tempRect,LTemp,0);/* Setup the Picture button */
$$endif Control.NonGraphic
$$EndLoop
$$Loop Control.type = UButton
SetupPlugin(theDialog,ResA_$Control.name$,Rec_$Worksheet.name$.Enable_$Control.name$,
ResA_N_$Control.name$,ResA_H_$Control.name$,sResA_$Control.name$);
$$EndLoop
$$Loop Control.type = Line
/* Draw a line, $Control.FullName$ */
$$if Control.GrayLine
PenPat(&qd.gray); /* Set the gray pen pattern */
$$endif Control.GrayLine
$$if Control.LineWidth ! 1
PenSize($Control.LineWidth$,$Control.LineWidth$);
$$endif Control.LineWidth
MoveTo($Control.LeftPosition$,$Control.TopPosition$); /* Horz,vert, Move to starting position */
LineTo($Control.RightPosition$,$Control.BottomPosition$); /* Horz,vert, Draw to the ending position */
$$if Control.LineWidth ! 1
PenSize(1,1);
$$endif Control.LineWidth
$$if Control.GrayLine
PenPat(&qd.black); /* Back to default pen pattern */
$$endif Control.GrayLine
$$EndLoop
$$Loop Control.type = HotRect
/* Draw a Hotspot or Rectangle, $Control.FullName$ */
SetupHotSpot(theDialog,ResA_$Control.name$,$Control.MakeHotSpot$,$Control.LineWidth$,
$Control.ShadowWidth$,sResA_$Control.name$,Rec_$Worksheet.name$.Enable_$Control.name$);
$$EndLoop
$$Loop Control.type = Sicn
/* Draw an Sicn */
$$if Control.Graphic
SetupIconSicn(theDialog,ResA_$Control.name$,Rec_$Worksheet.name$.Enable_$Control.name$,
ResA_N_$Control.name$,ResA_N_$Control.name$);
$$endif Control.Graphic
$$if Control.NonGraphic
SetupIconSicn(theDialog,ResA_$Control.name$,Rec_$Worksheet.name$.Enable_$Control.name$,
ResA_N_$Control.name$,ResA_H_$Control.name$);
$$endif Control.NonGraphic
$$EndLoop
Rec_$Worksheet.name$.FirstTime = false; /* Not first time anymore */
}
FilterValue = Filter_$Worksheet.name$(theDialog, theEvent, itemHit);/* Call the user routine */
CheckKeysInDialog(theDialog,&FilterValue,theEvent,itemHit);
return(FilterValue);
}
/* ======================================================= */
void InitA_$Worksheet.name$(void)
{
$$Loop Control.type = Button
Rec_$Worksheet.name$.Enable_$Control.name$ = $Control.Active$;
$$EndLoop Control.type
$$Loop Control.type = Icon
Rec_$Worksheet.name$.Enable_$Control.name$ = $Control.Active$;
$$EndLoop
$$Loop Control.type = Picture
$$if Control.NonGraphic
Rec_$Worksheet.name$.Enable_$Control.name$ = $Control.Active$;
$$endif Control.NonGraphic
$$EndLoop
$$Loop Control.type = UButton
Rec_$Worksheet.name$.Enable_$Control.name$ = $Control.Active$;
$$EndLoop
$$Loop Control.type = HotRect
Rec_$Worksheet.name$.Enable_$Control.name$ = $Control.Active$;
$$EndLoop
$$Loop Control.type = Sicn
Rec_$Worksheet.name$.Enable_$Control.name$ = $Control.Active$;
$$EndLoop
A_Init_$Worksheet.name$(); /* Tell the user routine */
}
/* ======================================================= */
void PA_$Worksheet.name$(void)
{
short itemHit; /* Get the selection ID in here */
AlertTHndl AlertResHandle; /* Resource handle for Alert */
Rect tempRect; /* Temp rect for moving the alert */
#if defined(powerc) || defined(__powerc)
ModalFilterUPP theFilter;
#endif
AlertResHandle = (AlertTHndl)GetResource('ALRT',ResA_$Worksheet.name$);/* Get the Alerts resource template handle */
HLock((Handle)AlertResHandle); /* Lock the resource down while we use it */
$$if Worksheet.Center
tempRect = (*AlertResHandle)->boundsRect; /* Get the alerts position and size */
$$if Worksheet.CenterHorz
tempRect.left = ((screenRect.bounds.right - screenRect.bounds.left) - (tempRect.right - tempRect.left)) / 2; /* Center Horz */
$$endif Worksheet.CenterHorz
$$if Worksheet.CenterVert
tempRect.top = ((screenRect.bounds.bottom - screenRect.bounds.top) - (tempRect.bottom - tempRect.top)) / 3; /* 1/3 vert */
$$endif Worksheet.CenterVert
tempRect.bottom = tempRect.top + ((*AlertResHandle)->boundsRect.bottom - (*AlertResHandle)->boundsRect.top);
tempRect.right = tempRect.left + ((*AlertResHandle)->boundsRect.right - (*AlertResHandle)->boundsRect.left);
(*AlertResHandle)->boundsRect = tempRect; /* Place the centered position back in the template */
$$endif
Rec_$Worksheet.name$.FirstTime = TRUE; /* Set the flag for the filter proc */
$$Link Worksheet.Open
/* Let the OS handle the Alert and wait for a result to be returned */
#if defined(powerc) || defined(__powerc)
theFilter = NewModalFilterProc(MyFilter);
#endif
$$if Alert.Stop
#if defined(powerc) || defined(__powerc)
itemHit = StopAlert(ResA_$Worksheet.name$,theFilter); /* Bring in the alert resource */
#else
itemHit = StopAlert(ResA_$Worksheet.name$,(ModalFilterProcPtr)&MyFilter);/* Bring in the alert resource */
#endif
$$endif
$$if Alert.Note
#if defined(powerc) || defined(__powerc)
itemHit = NoteAlert(ResA_$Worksheet.name$,theFilter); /* Bring in the alert resource */
#else
itemHit = NoteAlert(ResA_$Worksheet.name$,(ModalFilterProcPtr)&MyFilter);/* Bring in the alert resource */
#endif
$$endif
$$if Alert.Caution
#if defined(powerc) || defined(__powerc)
itemHit = CautionAlert(ResA_$Worksheet.name$,theFilter); /* Bring in the alert resource */
#else
itemHit = CautionAlert(ResA_$Worksheet.name$,(ModalFilterProcPtr)&MyFilter);/* Bring in the alert resource */
#endif
$$endif
HUnlock((Handle)AlertResHandle); /* Release the alert handle to float */
$$Loop Control.type = Button
$$if Control.HasLinks
$$if Control.Default
/* This is the default selection, when RETURN is pressed. */
$$endif
if (ResA_$Control.name$ == itemHit) /* $Control.FullName$,See if this control was selected */
{
$$Link Control.Select
}
$$endif
$$EndLoop Control.type
$$Loop Control.type = Icon
$$if Control.HasLinks
$$if Control.NonGraphic
if (ResA_$Control.name$ == itemHit) /* $Control.FullName$,See if this control was selected */
{
$$Link Control.Select
}
$$endif Control.NonGraphic
$$endif
$$EndLoop
$$Loop Control.type = Picture
$$if Control.HasLinks
$$if Control.NonGraphic
if (ResA_$Control.name$ == itemHit) /* $Control.FullName$,See if this control was selected */
{
$$Link Control.Select
}
$$endif Control.NonGraphic
$$endif
$$EndLoop
$$Loop Control.type = UButton
$$if Control.HasLinks
if (ResA_$Control.name$ == itemHit) /* $Control.FullName$,See if this control was selected */
{
$$Link Control.Select
}
$$endif
$$EndLoop
$$Loop Control.type = HotRect
$$if Control.HasLinks
$$if Control.HotSpot
if (ResA_$Control.name$ == itemHit) /* $Control.FullName$,See if this control was selected */
{
$$Link Control.Select
}
$$endif Control.HotSpot
$$endif
$$EndLoop
$$Loop Control.type = Sicn
$$if Control.HasLinks
$$if Control.NonGraphic
if (ResA_$Control.name$ == itemHit) /* $Control.FullName$,See if this control was selected */
{
$$Link Control.Select
}
$$endif Control.NonGraphic
$$endif
$$EndLoop
A_Hit_$Worksheet.name$(itemHit); /* Tell the user routine which item was selected */
$$Link Worksheet.Close
}
/* ======================================================= */
/* ======================================================= */
$$CloseFile
$$EndLoop